#pragma once

#include <string>
#include <vector>

static std::wstring LoadString(UINT id)
{
    const int buffSize = 1024;

    WCHAR buff[buffSize];
    memset( buff, 0, buffSize * sizeof(WCHAR));

    ::LoadString(_AtlBaseModule.GetResourceInstance(), id, buff, buffSize);
    return std::wstring(buff);
}

class FileUtils
{
public:
    static bool FileExists(const std::wstring& filePath)
    {
        WIN32_FIND_DATA fdata;
        memset((LPVOID)&fdata, 0, sizeof(WIN32_FIND_DATA));

        HANDLE hFind = INVALID_HANDLE_VALUE;

        if ((hFind = ::FindFirstFile(filePath.c_str(), &fdata)) != INVALID_HANDLE_VALUE ) {
            ::FindClose(hFind);
            return true;
        }        

        return false;
    }

    static long FileSize( const std::wstring& fileName )
    {
        HANDLE hFile = ::CreateFile(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
        if (hFile == INVALID_HANDLE_VALUE)
            return 0L;

        long size = ::GetFileSize( hFile, NULL );

        ::CloseHandle( hFile );

        return size != 0xFFFFFFFF ? size : 0L;
    }
};

// dir and filename concatenation operator
static std::wstring operator ^( const std::wstring &dirName, const std::wstring &fileName )
{
    std::wstring path = dirName[dirName.size()-1] == _T('\\') ? dirName : dirName + _T('\\');
    return path + fileName;
}
